//
//  TextDisplayViewController.m
//  RoadLine
//
//  Created by dllo on 15/4/23.
//  Copyright (c) 2015年 RedFireNoodles. All rights reserved.
//

#import "TextDisplayViewController.h"
#import "Singleton.h"

#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height


@interface TextDisplayViewController ()

@property(nonatomic, retain)UIView *backView;

@end

@implementation TextDisplayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 设置navigationBar上的字体颜色
    UILabel *titleLabelPrice = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
    titleLabelPrice.font = [UIFont boldSystemFontOfSize:18];
    titleLabelPrice.textColor = [UIColor whiteColor];
    titleLabelPrice.backgroundColor = [UIColor clearColor];
    titleLabelPrice.text = self.placeName;
    self.navigationItem.titleView = [titleLabelPrice autorelease];
       
    //添加背景图片:
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backgroundimage"]];
    self.title = self.placeName;
    self.backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    self.backView.backgroundColor = [UIColor whiteColor];
    self.backView.alpha = 0.5;
    [self.view addSubview:self.backView];
    [_backView release];
    
    //label自适应文字
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    label.backgroundColor = [UIColor clearColor];
    label.numberOfLines = 0;
    label.font = [UIFont systemFontOfSize:18] ;
    label.adjustsFontSizeToFitWidth = YES;
    label.text = self.str;
    [self.view addSubview:label];
    label.tag = 1000;
    [label release];
    
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:17],NSFontAttributeName, nil];
    CGRect rect = [label.text boundingRectWithSize:CGSizeMake(375, 600) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    CGFloat height = rect.size.height;
    label.frame = CGRectMake(20, 15, WIDTH - 40, height);
    
    if ([Singleton shareSingleton].isNight) {
        [[Singleton shareSingleton] loadNightModeInfoFormDisk];
    }

}


- (void)setLightDayModel {

    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"backgroundimage"]];
    self.backView.backgroundColor = [UIColor clearColor];
    UILabel *lable = (UILabel *)[self.view viewWithTag:1000];
    lable.backgroundColor = [UIColor clearColor];
    lable.textColor = [UIColor blackColor];
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:246/255.0 green:85/255.0 blue:91/255.0 alpha:1];
}



- (void)setNightDayModel {
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"blackPicture"]];

   self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"blackPicture"]];

    self.backView.backgroundColor = [UIColor blackColor];
    UILabel *lable = (UILabel *)[self.view viewWithTag:1000];
    lable.backgroundColor = [UIColor blackColor];
    lable.textColor= [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:4/255.0 green:165/255.0 blue:171/255.0 alpha:1];
    
}

-(void)dealloc{

    [_backView release];

    [super dealloc];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
